Ext.namespace('VAS');

VAS.UserPasswordEditWindow = function($config) {
	var _this = this;
    var form = new Ext.form.FormPanel({
	    labelWidth: 80,
	    labelAlign:'left',
	    minButtonWidth:40,
	    buttonAlign:'center',
	    url:'admin/system/UserAction!updatePassword.action',
	    frame:true,
		width:'100%',
		bodyStyle:'padding-top:20px; padding-left:90px; padding-bottom:20px',
	    items: [
            	{
	                layout: 'form',
			    	items:[{
			    		id:'firstT',
				        xtype:'textfield',
				        fieldLabel:'旧密码',
				        name:'oldPassword',
				        inputType:'password',
				        labelStyle : "width:100px;text-align:left;color:red",
				        allowBlank:false,
				      	blankText:'旧密码不能为空!',
				        maxLength:50,
                		maxLengthText : "长度不能超过50个字符"
				    },{
				    	xtype:'textfield',
				      	fieldLabel: '新密码',
				      	id:'newPassword',
				      	name: 'newPassword',
				      	inputType:'password',
				      	labelStyle : "width:100px;text-align:left;color:red",
				      	allowBlank:false,
					    blankText:'新密码不能为空!',
					    maxLength:50,
                		maxLengthText : "长度不能超过50个字符"
				    },{
				   		xtype:'textfield',
				      	fieldLabel: '确认新密码',
				      	name: 'confirmPassword',
				      	inputType:'password',
				      	labelStyle : "width:100px;text-align:left;color:red",
				      	allowBlank:false,
				      	blankText:'确认新密码不能为空!',
				      	maxLength:50,
                		maxLengthText : "长度不能超过50个字符"
				    }]
            	}
           ]
	})
	
	var modifyBtn = {
       text	: '修改',
       handler : function() {
   			var _form = form.getForm();
			if(_form.isValid()){
				if(_form.findField('newPassword').getValue()!==_form.findField('confirmPassword').getValue()){
					Ext.Msg.alert('提示','新密码不一致，请重新输入');
					_form.reset();
					return;
				}
				_form.submit({
		              url: _form.url,
					  waitTitle: '正在提交',
		              waitMsg: '正在向服务器发送请求',
		              clientValidation: true,
					  success :function(form,action){
							Ext.Msg.alert('提示','提交保存成功!',function(){ 
								_this.close();
							});
					  },
					  failure :function(form,action){
							alertFailure(action.result);
							_form.reset();
					 }
		        });
			}
       }
	};
	var resetBtn = {
		text: '重置',
		handler:function(){
			form.getForm().reset();
		}
	};
	var closeBtn = {
   		text:'关闭',
   		handler:function(){
   			this.ownerCt.ownerCt.close();
   		}
	};
	
	var thisConfig = {
		closable : true,
		autoScroll : true,
		modal:true,
		items : form,
		buttons: [modifyBtn, resetBtn, closeBtn],
		buttonAlign : 'center'
	};
	var _config = $config || {};

	Ext.apply(_this, Ext.apply(thisConfig, _config));
	VAS.UserPasswordEditWindow.superclass.constructor.call(_this);
};
Ext.extend(VAS.UserPasswordEditWindow,VAS.BasicWindow,{

});

Ext.reg('userPassword-win',VAS.UserPasswordEditWindow);

